//
// Created by Administrator on 2022/3/26.
//

#pragma once

#include <string>
#include <unordered_map>
#include <vector>
#include <boost/lexical_cast.hpp>

#include "../stringUtil.h"
using namespace std;
#include "../lexicalCast.hpp"

namespace TinyRPC{




class Config {

public:
    using ConfigMap = unordered_map<string, string>;
    static void init(const string& filePath);
    template<typename T, typename ValueCast = LexicalCast<T>>
    static T LookUp(string key, T defaultValue){
        auto it = configMap.find(key);
        if(it != configMap.end()){
            return ValueCast()(it->second);
        }else{
            return defaultValue;
        }
    }
    template<typename T, typename ValueCast = LexicalCast<T>>
    static T LookUp(string key){
        auto it = configMap.find(key);
        if(it != configMap.end()){
            return ValueCast()(it->second);
        }else{
            return T();
        }
    }
private:

    static ConfigMap configMap;

    static void parseLine(const string & line);
};



}
